unit PosicaoEstoque;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, ComCtrls, ActnList, Grids, DBGrids, DB, DBTables;

type
  TFormPosicaoEstoque = class(TForm)
    ActTotal: TActionList;
    ActionVoltar: TAction;
    ListView2: TListView;
    ImageList1: TImageList;
    QueryItemEstoque: TQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    QueryItemEstoqueunidade: TStringField;
    QueryItemEstoqueid: TIntegerField;
    QueryItemEstoquenome: TStringField;
    QueryItemEstoquenk: TStringField;
    QueryItemEstoqueid_unidade: TIntegerField;
    QueryItemEstoquequantidade: TFloatField;
    QueryItemEstoqueID_ST: TIntegerField;
    QueryItemEstoqueID_TP: TIntegerField;
    QueryItemEstoqueDT: TStringField;
    procedure ListView2Click(Sender: TObject);
    procedure FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ActionVoltarExecute(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure QueryItemEstoquequantidadeGetText(Sender: TField;
      var Text: String; DisplayText: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormPosicaoEstoque: TFormPosicaoEstoque;

implementation

{$R *.dfm}

procedure TFormPosicaoEstoque.ListView2Click(Sender: TObject);
var List: TListView;
begin
  if TListView(Sender).Selected <> nil then
  begin
        List := TlistView(Sender);
        ActTotal.Actions[List.Selected.StateIndex].Execute;
  end;

end;

procedure TFormPosicaoEstoque.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  if Key = VK_ESCAPE then
     self.close;
end;

procedure TFormPosicaoEstoque.ActionVoltarExecute(Sender: TObject);
begin
  self.close;
end;

procedure TFormPosicaoEstoque.FormActivate(Sender: TObject);
begin
  QueryItemEstoque.Open;
end;

procedure TFormPosicaoEstoque.QueryItemEstoquequantidadeGetText(
  Sender: TField; var Text: String; DisplayText: Boolean);
begin
    Text := formatfloat('###,###,###0.000', QueryItemEstoque.FieldByName('quantidade').AsFloat);
end;

end.
